package com.xcity.game.task.detector;

import com.alibaba.fastjson.JSONObject;
import com.xcity.game.task.Task;
import com.xcity.game.task.TaskDetector;
import com.xcity.game.task.TaskDetectorLabel;

/**
 * <pre>
 * 宠物清洗
 * 1个参数:
 * 1.清洗次数
 * </pre>
 * @author yang.li
 *
 */
@TaskDetectorLabel(TaskDetector.WASH_PET)
public class WashPetTaskDetector implements TaskDetector {

	static final String KEY = String.valueOf(WASH_PET);
	
	@Override
	public boolean isFinish(Task task) {
		int n = task.getTemplate().getConditions()[0];
		return task.getArchive().getIntValue(KEY) >= n;
	}

	@Override
	public void onArchive(Task task, Object... vals) {
		// { 12: n }
		JSONObject archive = task.getArchive();
		archive.put(KEY, archive.getIntValue(KEY) + 1);
	}

}
